Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(684)

Side by Side Diff: mojo/public/python/mojo_system.pyx

Issue 1364463006: Make Python not support "all or none" for two-phase data pipe read/write. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/public/dart/tools/fetch_dart_packages.py ('k') | mojo/python/tests/system_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 # distutils language = c++ 5 # distutils language = c++
6 6
7 cimport c_core 7 cimport c_core
8 cimport c_export # needed so the init function gets exported 8 cimport c_export # needed so the init function gets exported
9 cimport c_thunks 9 cimport c_thunks
10 10
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 cdef uint32_t input_buffer_length = buffer_as_buffer.len 484 cdef uint32_t input_buffer_length = buffer_as_buffer.len
485 cdef c_core.MojoResult res = c_core.MojoWriteData(self._mojo_handle, 485 cdef c_core.MojoResult res = c_core.MojoWriteData(self._mojo_handle,
486 buffer_as_buffer.buf, 486 buffer_as_buffer.buf,
487 &input_buffer_length, 487 &input_buffer_length,
488 flags) 488 flags)
489 if res == c_core.MOJO_RESULT_OK: 489 if res == c_core.MOJO_RESULT_OK:
490 return (res, input_buffer_length) 490 return (res, input_buffer_length)
491 return (res, None) 491 return (res, None)
492 492
493 def BeginWriteData(self, 493 def BeginWriteData(self,
494 min_size=None, 494 flags=WRITE_DATA_FLAG_NONE):
495 flags=WRITE_DATA_FLAG_NONE):
496 """ 495 """
497 Begins a two-phase write to the data pipe producer. 496 Begins a two-phase write to the data pipe producer.
498 497
499 This method can only be used on a producer handle obtained from 498 This method can only be used on a producer handle obtained from
500 |DataPipe()|. 499 |DataPipe()|.
501 500
502 This method returns a tuple (code, two_phase_buffer). 501 This method returns a tuple (code, two_phase_buffer).
503 - If code is RESULT_OK, two_phase_buffer is a writable 502 - If code is RESULT_OK, two_phase_buffer is a writable
504 DataPipeTwoPhaseBuffer 503 DataPipeTwoPhaseBuffer
505 - Otherwise, two_phase_buffer is None. 504 - Otherwise, two_phase_buffer is None.
506 505
507 See mojo/public/c/system/data_pipe.h 506 See mojo/public/c/system/data_pipe.h
508 """ 507 """
509 cdef void* out_buffer 508 cdef void* out_buffer
510 cdef uint32_t out_size = 0 509 cdef uint32_t out_size = 0
511 if min_size:
512 flags |= c_core.MOJO_WRITE_DATA_FLAG_ALL_OR_NONE
513 out_size = min_size
514 cdef c_core.MojoResult res = c_core.MojoBeginWriteData(self._mojo_handle, 510 cdef c_core.MojoResult res = c_core.MojoBeginWriteData(self._mojo_handle,
515 &out_buffer, 511 &out_buffer,
516 &out_size, 512 &out_size,
517 flags) 513 flags)
518 if res != c_core.MOJO_RESULT_OK: 514 if res != c_core.MOJO_RESULT_OK:
519 return (res, None) 515 return (res, None)
520 cdef _NativeMemoryView view_buffer = _NativeMemoryView(self) 516 cdef _NativeMemoryView view_buffer = _NativeMemoryView(self)
521 view_buffer.Wrap(out_buffer, out_size, read_only=False) 517 view_buffer.Wrap(out_buffer, out_size, read_only=False)
522 return (res, DataPipeTwoPhaseBuffer(self, memoryview(view_buffer), False)) 518 return (res, DataPipeTwoPhaseBuffer(self, memoryview(view_buffer), False))
523 519
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 See mojo/public/c/system/data_pipe.h 554 See mojo/public/c/system/data_pipe.h
559 """ 555 """
560 cdef uint32_t num_bytes = 0 556 cdef uint32_t num_bytes = 0
561 cdef c_core.MojoResult res = c_core.MojoReadData( 557 cdef c_core.MojoResult res = c_core.MojoReadData(
562 self._mojo_handle, 558 self._mojo_handle,
563 NULL, 559 NULL,
564 &num_bytes, 560 &num_bytes,
565 flags|c_core.MOJO_READ_DATA_FLAG_QUERY) 561 flags|c_core.MOJO_READ_DATA_FLAG_QUERY)
566 return (res, num_bytes) 562 return (res, num_bytes)
567 563
568 def BeginReadData(self, min_size=None, flags=READ_DATA_FLAG_NONE): 564 def BeginReadData(self, flags=READ_DATA_FLAG_NONE):
569 """ 565 """
570 Begins a two-phase read to the data pipe consumer. 566 Begins a two-phase read to the data pipe consumer.
571 567
572 This method can only be used on a consumer handle obtained from 568 This method can only be used on a consumer handle obtained from
573 |DataPipe()|. 569 |DataPipe()|.
574 570
575 This method returns a tuple (code, two_phase_buffer). 571 This method returns a tuple (code, two_phase_buffer).
576 - If code is RESULT_OK, two_phase_buffer is a readable 572 - If code is RESULT_OK, two_phase_buffer is a readable
577 DataPipeTwoPhaseBuffer 573 DataPipeTwoPhaseBuffer
578 - Otherwise, two_phase_buffer is None. 574 - Otherwise, two_phase_buffer is None.
579 575
580 See mojo/public/c/system/data_pipe.h 576 See mojo/public/c/system/data_pipe.h
581 """ 577 """
582 cdef const void* out_buffer 578 cdef const void* out_buffer
583 cdef uint32_t out_size = 0 579 cdef uint32_t out_size = 0
584 if min_size:
585 flags |= c_core.MOJO_READ_DATA_FLAG_ALL_OR_NONE
586 out_size = min_size
587 cdef c_core.MojoResult res = c_core.MojoBeginReadData(self._mojo_handle, 580 cdef c_core.MojoResult res = c_core.MojoBeginReadData(self._mojo_handle,
588 &out_buffer, 581 &out_buffer,
589 &out_size, 582 &out_size,
590 flags) 583 flags)
591 if res != c_core.MOJO_RESULT_OK: 584 if res != c_core.MOJO_RESULT_OK:
592 return (res, None) 585 return (res, None)
593 cdef _NativeMemoryView view_buffer = _NativeMemoryView(self) 586 cdef _NativeMemoryView view_buffer = _NativeMemoryView(self)
594 view_buffer.Wrap(out_buffer, out_size, read_only=True) 587 view_buffer.Wrap(out_buffer, out_size, read_only=True)
595 return (res, DataPipeTwoPhaseBuffer(self, memoryview(view_buffer), True)) 588 return (res, DataPipeTwoPhaseBuffer(self, memoryview(view_buffer), True))
596 589
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 return self.__run_loop.PostDelayedTask(runnable, delay) 787 return self.__run_loop.PostDelayedTask(runnable, delay)
795 788
796 @staticmethod 789 @staticmethod
797 def Current(): 790 def Current():
798 if hasattr(_RUN_LOOPS, 'loop'): 791 if hasattr(_RUN_LOOPS, 'loop'):
799 return _RUN_LOOPS.loop() 792 return _RUN_LOOPS.loop()
800 return None 793 return None
801 794
802 795
803 _ASYNC_WAITER = mojo_system_impl.AsyncWaiter() 796 _ASYNC_WAITER = mojo_system_impl.AsyncWaiter()
OLDNEW
« no previous file with comments | « mojo/public/dart/tools/fetch_dart_packages.py ('k') | mojo/python/tests/system_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698